package org.example.entity;

import com.baomidou.mybatisplus.annotation.*;

import java.time.LocalDateTime;import java.util.Date;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;import javax.persistence.PrePersist;import javax.persistence.PreUpdate;

/**
 * 会议信息表
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
@TableName(value = "meeting")
public class Meeting {
    /**
     * 会议ID（自增主键）
     */
    @TableId(value = "id", type = IdType.AUTO)
    private Integer id;

    /**
     * 会议标题
     */
    @TableField(value = "title",exist = true)
    private String title;

    /**
     * 关联会议室ID
     */
    @TableField(value = "room_id",exist = true)
    private Integer roomId;

    /**
     * 会议开始时间
     */
    @TableField(value = "start_time",exist = true)
    private LocalDateTime startTime;

    /**
     * 会议结束时间
     */
    @TableField(value = "end_time",exist = true)
    private LocalDateTime endTime;

    /**
     * 状态（0-未开，1-进行中，2-已结束，3-逾期）
     */
    @TableField(value = "`status`",exist = true)
    private Byte status;

    /**
     * 创建时间
     */
    @TableField(value = "create_time", exist = true, fill = com.baomidou.mybatisplus.annotation.FieldFill.INSERT)
    private LocalDateTime createTime;

    /**
     * 删除
     */
    @TableField(value = "deleted", exist = true)
    private Integer deleted;
    /**
     * 更新时间
     */
    @TableField(value = "update_time", exist = true, fill = FieldFill.INSERT_UPDATE)
    private LocalDateTime updateTime;

    /**
     * 数据创建时自动填充时间
     */
    @PrePersist
    public void prePersist() {
        this.createTime = LocalDateTime.now();
        this.updateTime = LocalDateTime.now();
        this.deleted = 0; // 默认未删除
    }

    /**
     * 数据更新时自动更新时间
     */
    @PreUpdate
    public void preUpdate() {
        this.updateTime = LocalDateTime.now();
    }
}